<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="条形码" prop="barCode">
        <el-input v-model="queryParams.barCode" placeholder="请输入条形码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="资产编号" prop="assetNo">
        <el-input v-model="queryParams.assetNo" placeholder="请输入资产编号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="型号" prop="modelCode">
        <el-input v-model="queryParams.modelCode" placeholder="请输入型号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="类型" prop="typeCode">
        <el-input v-model="queryParams.typeCode" placeholder="请输入类型" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="接线方式" prop="wiringMode">
        <el-select v-model="queryParams.wiringMode" placeholder="请选择接线方式" clearable>
          <el-option v-for="dict in dict.type.at_wiring_mode" :key="dict.value" :label="dict.label"
            :value="dict.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="mdLcEquipList" @selection-change="handleSelectionChange">
      <el-table-column label="终端ID" align="center" prop="lcEquipId" />
      <el-table-column label="操作标识" align="center" prop="operId" v-if="false" />
      <el-table-column label="物料号" align="center" prop="erpBatchNo" />
      <el-table-column label="条形码" align="center" prop="barCode" />
      <el-table-column label="资产编号" align="center" prop="assetNo" />
      <el-table-column label="出厂编号" align="center" prop="madeNo" />
      <el-table-column label="到货批次号" align="center" prop="lotNo" min-width="100px" />
      <el-table-column label="合同标识" align="center" prop="contractId" v-if="fasle" />
      <el-table-column label="型号" align="center" prop="modelCode" />
      <el-table-column label="类型" align="center" prop="typeCode" />
      <el-table-column label="生产厂家" align="center" prop="manufacturer" />
      <el-table-column label="采集方式" align="center" prop="collMode" />
      <el-table-column label="出厂日期" align="center" prop="madeDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.madeDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="到货接收ID" align="center" prop="rcvId" min-width="100px" />
      <el-table-column label="产权单位编号" align="center" prop="prOrg" min-width="110px" />
      <el-table-column label="管理单位编号" align="center" prop="deptNo" min-width="110px" />
      <el-table-column label="营销工号" align="center" prop="removeOperatorNo" />
      <el-table-column label="拆除日期" align="center" prop="rmvDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.rmvDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="建挡人" align="center" prop="docCreatorNo" />
      <el-table-column label="建档日期" align="center" prop="docCreateDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.docCreateDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="安装人" align="center" prop="installerNo" />
      <el-table-column label="校验营销工号" align="center" prop="checkerNo" min-width="110px" />
      <el-table-column label="安装日期" align="center" prop="instDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.instDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="校验日期" align="center" prop="chkDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.chkDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="报废人" align="center" prop="descardOperatorNo" />
      <el-table-column label="报废日期" align="center" prop="descardDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.descardDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="curStatusCode" />
      <el-table-column label="责任人编号" align="center" prop="personRespNo" min-width="100px" />
      <el-table-column label="责任人的电话号码" align="center" prop="tel" min-width="130px" />
      <el-table-column label="使用年限" align="center" prop="lifeTime" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="投运的时间" align="center" prop="deliverDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.deliverDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="投运备注" align="center" prop="deliverRemark" />
      <el-table-column label="周转箱条形码" align="center" prop="boxBarCode" min-width="110px" />
      <el-table-column label="储位名称" align="center" prop="storeLocName" />
      <el-table-column label="库房名称" align="center" prop="whName" min-width="120px" />
      <el-table-column label="库区名称" align="center" prop="whAreaname" />
      <el-table-column label="存放区名称" align="center" prop="storeAreaName" min-width="120px" />
      <el-table-column label="附属设备分类" align="center" prop="attachMeterFlag" min-width="250px">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.at_attach_meter_flag" :value="scope.row.attachMeterFlag" />
        </template>
      </el-table-column>
      <el-table-column label="载波模块属性标识" align="center" prop="carrierWaveId" min-width="130px" v-if="false" />
      <el-table-column label="硬件版本" align="center" prop="hardVer" />
      <el-table-column label="软件版本" align="center" prop="softVer" />
      <el-table-column label="采集终端通讯地址" align="center" prop="terminalAddr" min-width="130px" />
      <el-table-column label="载波芯片厂商" align="center" prop="carrierWaveChipManufacturer" min-width="100px" />
      <el-table-column label="载波类型" align="center" prop="carrierWaveType" />
      <el-table-column label="载波中心频点" align="center" prop="carrierWaveCenterFreq" min-width="100px" />
      <el-table-column label="载波芯片型号" align="center" prop="carrierWaveModel" min-width="100px" />
      <el-table-column label="载波软件版本" align="center" prop="carrierWaveVer" min-width="100px" />
      <el-table-column label="通讯方式 " align="center" prop="commMode" />
      <el-table-column label="采集终端规格 " align="center" prop="specCode" min-width="100px" />
      <el-table-column label="上行通信信道" align="center" prop="upChannelNo" min-width="100px" />
      <el-table-column label="下行通信信道" align="center" prop="downChannelNo" min-width="100px" />
      <el-table-column label="通信规约" align="center" prop="protocolCode" />
      <el-table-column label="参比电压" align="center" prop="referenceVoltCode" />
      <el-table-column label="参比电流" align="center" prop="referenceCurrentCode" />
      <el-table-column label="参比频率" align="center" prop="referenceFreqCode" />
      <el-table-column label="产权所属" align="center" prop="prCode" />
      <el-table-column label="接线方式" align="center" prop="wiringMode">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.at_wiring_mode" :value="scope.row.wiringMode" />
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" min-width="135px">
        <template slot-scope="scope">
          <el-button size="small" type="primary" @click="taskDetails(scope.row)">采集终端详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 采集终端资产信息详情 -->
    <el-dialog :title="title" :visible.sync="open" width="1300px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="操作标识" prop="operId" v-if="false">
              <el-input v-model="form.operId" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="物料号" prop="erpBatchNo">
              <span>{{ form.erpBatchNo }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="条形码" prop="barCode">
              <span>{{ form.barCode }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="载波类型" prop="carrierWaveType">
              <span>{{ form.carrierWaveType }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="资产编号" prop="assetNo">
              <span>{{ form.assetNo }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="出厂编号" prop="madeNo">
              <span>{{ form.madeNo }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="到货批次号" prop="lotNo">
              <span>{{ form.lotNo }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="合同标识" prop="contractId" v-if="false">
              <el-input v-model="form.contractId" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="型号" prop="modelCode">
              <span>{{ form.modelCode }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="类型" prop="typeCode">
              <span>{{ form.typeCode }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="接线方式" prop="wiringMode">
              <span>{{ wiringMode }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="生产厂家" prop="manufacturer">
              <span>{{ form.manufacturer }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="采集方式" prop="collMode">
              <span>{{ form.collMode }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="出厂日期" prop="madeDate">
              <span>{{ form.madeDate }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="到货接收ID" prop="rcvId">
              <span>{{ form.rcvId }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="产权单位编号" prop="prOrg">
              <span>{{ form.prOrg }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="管理单位编号" prop="deptNo">
              <span>{{ form.deptNo }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="营销工号" prop="removeOperatorNo">
              <span>{{ form.removeOperatorNo }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="拆除日期" prop="rmvDate">
              <span>{{ form.rmvDate }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="建挡人" prop="docCreatorNo">
              <span>{{ form.docCreatorNo }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="建档日期" prop="docCreateDate">
              <span>{{ form.docCreateDate }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="安装人" prop="installerNo">
              <span>{{ form.installerNo }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="校验营销工号" prop="checkerNo">
              <span>{{ form.checkerNo }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="安装日期" prop="instDate">
              <span>{{ form.instDate }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="校验日期" prop="chkDate">
              <span>{{ form.chkDate }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="报废人" prop="descardOperatorNo">
              <span>{{ form.descardOperatorNo }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="报废日期" prop="descardDate">
              <span>{{ form.descardDate }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="状态" prop="curStatusCode">
              <span>{{ form.curStatusCode }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="责任人编号" prop="personRespNo">
              <span>{{ form.personRespNo }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="责任人的电话号码" prop="tel">
              <span>{{ form.tel }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="使用年限" prop="lifeTime">
              <span>{{ form.lifeTime }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="投运的时间" prop="deliverDate">
              <span>{{ form.deliverDate }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="周转箱条形码" prop="boxBarCode">
              <span>{{ form.boxBarCode }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="储位名称" prop="storeLocName">
              <span>{{ form.storeLocName }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="库房名称" prop="whName">
              <span>{{ form.whName }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="库区名称" prop="whAreaname">
              <span>{{ form.whAreaname }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="存放区名称" prop="storeAreaName">
              <span>{{ form.storeAreaName }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="附属设备分类" prop="equipment">
              <span>{{ equipment }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="载波模块属性标识" prop="carrierWaveId" v-if="false">
              <el-input v-model="form.carrierWaveId" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="硬件版本" prop="hardVer">
              <span>{{ form.hardVer }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="软件版本" prop="softVer">
              <span>{{ form.softVer }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="产权所属" prop="prCode">
              <span>{{ form.prCode }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="采集终端通讯地址" prop="terminalAddr">
              <span>{{ form.terminalAddr }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="载波芯片厂商" prop="carrierWaveChipManufacturer">
              <span>{{ form.carrierWaveChipManufacturer }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="载波中心频点" prop="carrierWaveCenterFreq">
              <span>{{ form.carrierWaveCenterFreq }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="载波芯片型号" prop="carrierWaveModel">
              <span>{{ form.carrierWaveModel }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="载波软件版本" prop="carrierWaveVer">
              <span>{{ form.carrierWaveVer }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="通讯方式" prop="commMode">
              <span>{{ form.commMode }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="采集终端规格" prop="specCode">
              <span>{{ form.specCode }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="上行通信信道" prop="upChannelNo">
              <span>{{ form.upChannelNo }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="下行通信信道" prop="downChannelNo">
             <span>{{ form.downChannelNo }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="通信规约" prop="protocolCode">
              <span>{{ form.protocolCode }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="参比电压" prop="referenceVoltCode">
              <span>{{ form.referenceVoltCode }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="参比电流" prop="referenceCurrentCode">
             <span>{{ form.referenceCurrentCode }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="参比频率" prop="referenceFreqCode">
              <span>{{ form.referenceFreqCode }}</span>
            </el-form-item>
          </el-col>  
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <span>{{ form.remark }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="投运备注" prop="deliverRemark">
              <span>{{ form.deliverRemark }}</span>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">返 回</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listMdLcEquip, getMdLcEquip } from "@/api/storage/mdLcEquip";


export default {
  name: "MdLcEquip",
  dicts: ["at_attach_meter_flag", "at_wiring_mode"],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 采集终端资产信息表格数据
      mdLcEquipList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        barCode: null,
        assetNo: null,
        modelCode: null,
        typeCode: null,
        wiringMode: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      wiringMode: "",
      equipment: ""
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询采集终端资产信息列表 */
    getList() {
      this.loading = true;
      listMdLcEquip(this.queryParams).then(response => {
        this.mdLcEquipList = response.rows;
        console.log(response)
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        lcEquipId: null,
        operId: null,
        erpBatchNo: null,
        barCode: null,
        assetNo: null,
        madeNo: null,
        lotNo: null,
        contractId: null,
        modelCode: null,
        typeCode: null,
        manufacturer: null,
        collMode: null,
        madeDate: null,
        rcvId: null,
        prOrg: null,
        deptNo: null,
        removeOperatorNo: null,
        rmvDate: null,
        docCreatorNo: null,
        docCreateDate: null,
        installerNo: null,
        checkerNo: null,
        instDate: null,
        chkDate: null,
        descardOperatorNo: null,
        descardDate: null,
        curStatusCode: null,
        personRespNo: null,
        tel: null,
        lifeTime: null,
        remark: null,
        deliverDate: null,
        deliverRemark: null,
        boxBarCode: null,
        storeLocId: null,
        whId: null,
        whAreaId: null,
        storeAreaId: null,
        attachMeterFlag: null,
        carrierWaveId: null,
        hardVer: null,
        softVer: null,
        terminalAddr: null,
        carrierWaveChipManufacturer: null,
        carrierWaveType: null,
        carrierWaveCenterFreq: null,
        carrierWaveModel: null,
        carrierWaveVer: null,
        commMode: null,
        specCode: null,
        upChannelNo: null,
        downChannelNo: null,
        protocolCode: null,
        referenceVoltCode: null,
        referenceCurrentCode: null,
        referenceFreqCode: null,
        prCode: null,
        wiringMode: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.lcEquipId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 采集终端资产信息详情 */
    taskDetails(row) {
      this.reset();
      const lcEquipId = row.lcEquipId
      getMdLcEquip(lcEquipId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "终端资产信息详情";
        if(this.form.wiringMode == '1'){
          this.wiringMode = "单相"
        }else if(this.form.wiringMode == '2'){
          this.wiringMode = "三相三线"
        }else if(this.form.wiringMode == '3'){
          this.wiringMode = "三相四线"
        }
        if(this.form.attachMeterFlag == '0'){
          this.equipment = "普通采集终端"
        }else if(this.form.attachMeterFlag == '1'){
          this.equipment = "附属设备（带有远程通讯功能的电能表）"
        }else if(this.form.attachMeterFlag == '2'){
          this.equipment = "主设备（带有交采功能的采集终端）"
        }
      });
    },
  }
};
</script>
